﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;
using System.Reflection;
using System.Web;

namespace TheCup
{

    public class EclecticStablefordListEntry
    {
        public Player Player { get; set; }

        public string TiedPositionIndicator { get; set; }
        public int Position { get; set; }

        public int Total
        {
            get { return TotalOut + TotalIn; }
        }

        public int TotalOut
        {
            get { return S1 + S2 + S3 + S4 + S5 + S6 + S7 + S8 + S9; }
        }

        public int TotalIn
        {
            get { return S10 + S11 + S12 + S13 + S14 + S15 + S16 + S17 + S18; }
        }

        public int NumberOfRounds { get; set; }

        public int Property(string property, int hole)
        {
            PropertyInfo pi = this.GetType().GetProperty(property + hole);
            object result = pi.GetValue(this);
            return Int32.Parse(result.ToString());
        }

        public string ScoreCssClass(int hole)
        {
            int score = Property("S", hole);
            string result = string.Empty;
            switch (score)
            {
                case 5:
                    result = "albatros";
                    break;
                case 4:
                    result = "eagle";
                    break;
                case 3:
                    result = "birdie";
                    break;
                case 2:
                    result = "par";
                    break;
                case 1:
                    result = "bogey";
                    break;
                case 0:
                    result = "double";
                    break;
                
                default:
                    result = "worse";
                    break;
            }
            return result;
        }

        public int S1 { get; set; }
        public int S2 { get; set; }
        public int S3 { get; set; }
        public int S4 { get; set; }
        public int S5 { get; set; }
        public int S6 { get; set; }
        public int S7 { get; set; }
        public int S8 { get; set; }
        public int S9 { get; set; }
        public int S10 { get; set; }
        public int S11 { get; set; }
        public int S12 { get; set; }
        public int S13 { get; set; }
        public int S14 { get; set; }
        public int S15 { get; set; }
        public int S16 { get; set; }
        public int S17 { get; set; }
        public int S18 { get; set; }
    }

}